app.controller('BusDelayedShiftCtrl', function ($scope, $modalInstance, $modal, param, ajax, $filter, toaster) {
	$scope.param = param;
	if ($scope.param.data == null) {
		$scope.param.data = {};
	}
	$scope.timeRange = {};

	//状态
	// $scope.statusList = [
	// 	{ id: 0, name: "等待发布" },
	// 	{ id: 1, name: "等待报班" },
	// 	{ id: 2, name: "等待发班" },
	// 	{ id: 3, name: "运行中" },
	// 	{ id: 4, name: "已完成" },
	// 	{ id: 5, name: "晚点" },
	// 	{ id: 6, name: "塌班" },
	// 	{ id: 7, name: "被取消" }
	// ];
	// for (var i in $scope.statusList) {
	// 	if ($scope.statusList[i].id == $scope.param.data.status) {
	// 		$scope.statusList.selected = $scope.statusList[i];
	// 		break;
	// 	}
	// }

	$scope.oldTime = $scope.param.data.departTime;
	$scope.ok = function () {
		if ($scope.myForm.$valid) {
			// if ($scope.statusList.selected) {
			// 	$scope.param.data.status = $scope.statusList.selected.id;
			// }
			var newTime = new Date('1970/1/1 ' + $scope.departTime);
			if (newTime.getTime() > $scope.oldTime) {
				$scope.param.data.departTime = newTime;
				$scope.param.data.stationFilter = null;//防止json转换出错 实际并未修改filter
				$scope.param.data.template.stationFilter = null;
				$modalInstance.close($scope.param);
			} else {
				toaster.pop('warning', '提示', '发班时间必须大于修改前的时间！');
				return;
			}
		}
	};

	$scope.cancel = function () { $modalInstance.dismiss('cancel'); };
});